<?php

// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Home\Controller;
use OT\DataDictionary;
use Think\Model;

/**
 * 前台首页控制器
 * 主要获取首页聚合数据
 */
class BasisController extends HomeController{
    public function pictext(){    //图文菜单
        if (empty($id)) {
        } else {
            $User = M("pictext");
            $User->where("testid=" . $id . "")->delete();   //删除所选数据.
        }
        $idd=I("get.p",1);
        $a=($idd-1)*10;
        $b=10;
        $Model=M();
        $list=$Model->query("SELECT a.testid,a.headline,a.type,a.orderid,a.pageview,b.id,b.path,b.url FROM ot_pictext AS a LEFT JOIN ot_picture as b on a.cover=b.id ORDER BY a.testid DESC  LIMIT $a,$b");
        $row=count($Model->query("SELECT * FROM ot_pictext "));
        $this->assign("row",$row);
        $Page       = new \Think\Page($row,10);// 实例化分页类 传入总记录数和每页显示的记录数(25)
        $show       = $Page->show();// 分页显示输出
        $this->assign('list',$list);// 赋值数据集
        $this->assign('page',$show);// 赋值分页输出
        $this->display(); // 输出模板
    }
    public function pictext_edit(){      //图文菜单的编辑页面
        $post=I("post.");
        $testid=I("get.id");
        $this->assign("testid",$testid);
        if($post){
            $User=M("pictext");
            $data=$post;
            $User->where("testid=".$testid."")->save($data);
            $arr=$User->where("testid=".$testid."")->select();
            dump($User->getLastSql());
            $this->assign("arr",$arr);
            echo "Modify the information successfully";
            $this->display();
        }
        else{
            $User=M("pictext");
            $arr=$User->where("testid=".$testid."")->select();
            $this->assign("arr",$arr);
            $this->display();
        }
    }
    public function pictext_newly(){      //图文菜单新增信息页面
        $post=I("post.");
        if($post){
            $User=M("pictext");
            $testadd=$post;
            $User->add($testadd);
            dump($User->getLastSql());
            echo "The new information";
        }else{
        }
        $this->display();

    }
}